import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '/constant/app_info.dart';
import '/constant/system.dart';
import '/util/logger_util.dart';
import 'package:package_info/package_info.dart';

/// <summary>
/// todo: app 初始化
/// author：zwb
/// dateTime： 2021/11/3 11:53
/// filePath： lib/init/init_app.dart
/// desc:
/// <summary>
///
class InitApp{

  /// todo：app初始化类
  static init() {
    WidgetsFlutterBinding.ensureInitialized();
    /// 获取app包信息
    /// 安卓沉浸式
    System.immersive();
    /// 竖屏
    System.setHorizontalScreen();
  }

  /// todo：获取app信息
  static getAppInfo() async{
    if(kIsWeb) return; /// web端屏蔽 不支持
    PackageInfo packageInfo = await PackageInfo.fromPlatform();
    AppInfo.appName = packageInfo.appName;
    AppInfo.buildNumber = packageInfo.buildNumber;
    AppInfo.packageName = packageInfo.packageName;
    AppInfo.version = packageInfo.version;
    logger("${AppInfo()}",tag: "APP当前版本信息");
  }
}